package com.jic.member.impl;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.member.entity.MemberFootprint;
import com.jic.member.mapper.MemberFootprintMapper;
import com.jic.member.request.MemberFootprintRequest;
import com.jic.member.service.MemberFootprintService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 会员足迹记录表
 * @author : 
 * @email : 
 * @since : 2020-01-13 04:22:41
 * @version : v1.0.0
 */
@Service
public class MemberFootprintServiceImpl implements MemberFootprintService{

    @Autowired
    private MemberFootprintMapper memberFootprintMapper;

    @Override
    public long insert(MemberFootprint memberFootprint) {
        long flag = memberFootprintMapper.insert(memberFootprint);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return memberFootprintMapper.delete(id);
    }

    @Override
    public long update(MemberFootprint memberFootprint) {
        return memberFootprintMapper.update(memberFootprint);
    }

    @Override
    public MemberFootprint queryByPrimaryKey(Long id){
        return memberFootprintMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<MemberFootprint> query(MemberFootprint memberFootprint){
        return memberFootprintMapper.query(memberFootprint);
    }

    @Override
    public PageResult<MemberFootprint> queryPage(MemberFootprintRequest memberFootprintRequest, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        if(null !=memberFootprintRequest && memberFootprintRequest.getAdminOperate().getDeptType().getCode() != 0){
            memberFootprintRequest.setDeptId(memberFootprintRequest.getAdminOperate().getDeptId());
        }
        List<MemberFootprint> list = memberFootprintMapper.queryPage(startIndex, pageQuery.getLimit(), memberFootprintRequest);
        long count = memberFootprintMapper.queryPageCount(memberFootprintRequest);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }

    @Override
    public List<MemberFootprint> queryAll(MemberFootprintRequest memberFootprintRequest) {
        return memberFootprintMapper.queryAll(memberFootprintRequest);
    }
}